package com.duan.learn.collection;

import java.util.ArrayList;
import java.util.List;

public class ArrayListTest {

    private static final int SIZE = 100;
    private static List<Integer> list = new ArrayList<>(SIZE);


    public static void main(String[] args) throws Exception {
        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < SIZE; i++) {
                    list.add(i);
                }
            }
        });

        Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = SIZE; i < SIZE*2; i++) {
                    list.add(i);
                }
            }
        });

        thread1.start();
        thread2.start();
        Thread.sleep(1000);
        for(int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i) + ", ");
        }

    }
}
